package com.wujunshen.algorithm.leetcode.dynamic.programming;

/**
 * @author frank woo(吴峻申) <br>
 * email:<a href="mailto:frank_wjs@hotmail.com">frank_wjs@hotmail.com</a> <br>
 * @date 2022/8/1 21:36<br>
 */
public class 使用最小花费爬楼梯 {
        public int minCostClimbingStairs(int[] cost) {
            for (int i = 2; i < cost.length; i++) {
                cost[i] = Math.min(cost[i - 2], cost[i - 1]) + cost[i];
            }
            return Math.min(cost[cost.length - 2], cost[cost.length - 1]);
        }
}
